//Primera practica - Compiladores 2 - Semestre Uno 2012

package XML;

import Bitacora.*;
import java_cup.runtime.Symbol;

%%

%public
%class EscanerXML
%cup
%char
%line
%column
%full
%eofval{
    return new Symbol(SimbolosXML.EOF, yyline+1, yycolumn +1, yytext());
%eofval}

    LineTerminator = \r|\n|\r\n
    InputCharacter = [^\r\n]

// Comentarios

    Comment = {TraditionalComment} | {EndOfLineComment} 
    TraditionalComment = "/*" [^*] ~"*/" | "/*" "*"+ "/"
    EndOfLineComment = "//" {InputCharacter}* {LineTerminator}

// Tokens

    Letras = [a-zA-Z]*

    Cadena = [_]*{Letras} | [_]*{Letras} [_]*[a-zA-Z0-9]*

    Numero = 0 | [1-9][0-9]*

    Punto = "."

    Decimal = {Numero}{Punto}{Numero}

    new_line = \r|\n|\r\n;

    white_space	= {new_line} | [ \t\f]
	
%%

{Comment}   { /*Comentarios ignorados*/ }		

"xml"       {   return new Symbol(SimbolosXML.xml, yyline+1, yycolumn +1, yytext()); }
"version"   {   return new Symbol(SimbolosXML.version, yyline+1, yycolumn +1, yytext()); }
"class"     {   return new Symbol(SimbolosXML.clase, yyline+1, yycolumn +1, yytext()); }
"name"      {   return new Symbol(SimbolosXML.name, yyline+1, yycolumn +1, yytext()); }
"attributes"    {	return new Symbol(SimbolosXML.atributes, yyline+1, yycolumn +1, yytext()); }
"methods"   {   return new Symbol(SimbolosXML.metods, yyline+1, yycolumn +1, yytext()); }				
"relation"  {   return new Symbol(SimbolosXML.relation, yyline+1, yycolumn +1, yytext()); }
{Numero}    {   return new Symbol(SimbolosXML.numero, yyline+1, yycolumn +1, yytext()); }	
{Cadena}    {   return new Symbol(SimbolosXML.cadena, yyline+1, yycolumn +1, yytext()); }
{Decimal}   {   return new Symbol(SimbolosXML.decimal, yyline+1, yycolumn +1, yytext()); }
"<"         {	return new Symbol(SimbolosXML.menorque, yyline+1, yycolumn +1, yytext()); }				
">"         {	return new Symbol(SimbolosXML.mayorque, yyline+1, yycolumn +1, yytext()); }
"?"         {   return new Symbol(SimbolosXML.interrogacion, yyline+1, yycolumn +1, yytext()); }
"="         {   return new Symbol(SimbolosXML.igual, yyline+1, yycolumn +1, yytext()); }
"\""        {   return new Symbol(SimbolosXML.comillas, yyline+1, yycolumn +1, yytext()); }	
"/"         {   return new Symbol(SimbolosXML.diagonal, yyline+1, yycolumn +1, yytext()); }

{white_space}   { /* ignoramos espacios */ }

.|\n        {	IDE.Face.errores_lexicos.add(new Info(yytext(),yyline+1,yycolumn+1,0,"El caracter no pertenece al lenguaje.","Lexico")); }